from PyInstaller.utils.hooks import collect_all, collect_data_files

# 收集所有 Lightning 相关的包
datas = []
binaries = []
hiddenimports = []

# 收集各个包
for pkg in ['lightning', 'lightning_fabric', 'pytorch_lightning']:
    try:
        pkg_datas, pkg_binaries, pkg_hidden = collect_all(pkg)
        datas.extend(pkg_datas)
        binaries.extend(pkg_binaries)
        hiddenimports.extend(pkg_hidden)
    except:
        # 如果包不存在，继续
        pass

# 额外添加可能缺失的文件
extra_datas = collect_data_files('lightning_fabric')
datas.extend(extra_datas)